package com.c.ctgproject.ui.sell.parts

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.c.ctgproject.base.BaseViewModel
import com.c.ctgproject.http.ApiMethods
import com.c.ctgproject.utils.awaitSync
import com.c.ctgproject.utils.launch
import com.c.ctgproject.utils.userToken

/**
 *作者:LiBW
 *创建日期: 2020/9/8
 *描述: 配件销售列表ViewModel
 */
class PartsSellListViewModel : BaseViewModel() {
    private val mDetail = MutableLiveData<String>()
    val detail: LiveData<String> get() = mDetail

    fun getDetail(page: Int, size: Int) {
        launch({
            mDetail.value = ApiMethods.getApiService().soldAccessoriesAll(userToken, page, size).awaitSync()
        }, {
            mError.value = it.message.toString()
        })
    }
}